package com.ruoyi.informfrontend.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.informfrontend.domain.ServiceArticle;
import com.ruoyi.informfrontend.service.IServiceArticleService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 服务资讯Controller
 *
 * @author ruoyi
 * @date 2023-05-17
 */
@RestController
@RequestMapping("/serviceArticle")
public class ServiceArticleController extends BaseController
{
    @Autowired
    private IServiceArticleService serviceArticleService;

    /**
     * 查询服务资讯列表
     */
    @GetMapping("/list")
    public TableDataInfo list(ServiceArticle serviceArticle)
    {
        startPage();
        List<ServiceArticle> list = serviceArticleService.selectServiceArticleList(serviceArticle);
        return getDataTable(list);
    }

    /**
     * 查询服务资讯列表
     */
    @GetMapping("/app")
    public AjaxResult app(ServiceArticle serviceArticle)
    {
        startPage();
        List<ServiceArticle> list = serviceArticleService.selectServiceArticleList(serviceArticle);
        return success(list);
    }


    /**
     * 获取服务资讯详细信息
     */
    @GetMapping(value = "/getOne")
    public AjaxResult getOne(@RequestParam("id") Long id)
    {
        return success(serviceArticleService.selectServiceArticleById(id));
    }

    /**
     * 新增服务资讯
     */
    @PostMapping
    public AjaxResult add(@RequestBody ServiceArticle serviceArticle)
    {
        return toAjax(serviceArticleService.insertServiceArticle(serviceArticle));
    }

    /**
     * 修改服务资讯
     */
    @PutMapping
    public AjaxResult edit(@RequestBody ServiceArticle serviceArticle)
    {
        return toAjax(serviceArticleService.updateServiceArticle(serviceArticle));
    }

    /**
     * 删除服务资讯
     */
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(serviceArticleService.deleteServiceArticleByIds(ids));
    }
}
